import Vue from 'vue'

export default function () {
  const that = this

  return new Vue({
    components: {
      Splash: that.splash
    },
    data: {
      native: false,
      debug: that.debug,
      status: true
    },
    template: `
      <Splash
        id='splash'
        v-if='status'
        :debug='debug'
        :native='native'
        @next='createApp'
        @end='end'
      />
    `,
    created() {
      if(typeof that.native === 'function')
        that.native((status) => {
          that.native = this.native = status
        })
    },
    methods: {
      createApp(next) {
        that.createApp()
        next()
      },
      end() {
        this.status = false
        this.$nextTick(() => {
          this.$destroy()
        })
      }
    }
  }).$mount('app')

}
